package h0722;

import java.util.Arrays;
import java.util.Scanner;
/**
  * @description 求符合要求的结对方式
  * @author 不知名帅哥
  * @date 2024/7/22 15:46
  * @version 1.0
*/
public class FindMatchMethod {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }
        int target=sc.nextInt();
        int methods=getResult(arr,target);
        System.out.println(methods);
    }

    private static int getResult(int[] arr,int target) {
        Arrays.sort(arr);
        int ans=0;
        for (int i = 0; i < arr.length; i++) {
            for (int j = arr.length - 1; j >= i+1; j--) {
                if (arr[i]+arr[j]==target){
                    ans++;
                } else if (arr[i]+arr[j]<target){ //内层循环遍历无法满足要求。
                    break;
                }
            }
        }
        return ans;
    }
}
